package com.zhibang.config.security;

import com.alibaba.fastjson2.JSON;
import com.zhibang.util.Result;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Component;
import java.io.IOException;

/**
 * @author: ly
 * @date: 2025-03-24 09:48
 */
@Component
public class LogoutSuccessHandler implements org.springframework.security.web.authentication.logout.LogoutSuccessHandler {
    @Override
    public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException{
        //响应JSON数据
        response.setContentType("application/json;charset=utf-8");
        Result<Object> r = Result.ok("注销成功");
        response.getWriter().print(JSON.toJSONString(r));
    }

}
